package com.putao.album.dialog;

import android.content.Context;
import android.content.DialogInterface;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.putao.album.R;
import com.putao.album.util.StringHelper;
import com.putao.album.util.ViewHelper;

/**
 * Created by jidongdong on 15/4/29.
 */
public class ConfirmDialogBuilder extends DialogBuilder {

    public ConfirmDialogBuilder(Context context) {
        super(context);
    }

    @Override
    protected int getContentViewId() {
        return R.layout.dialog_pt_confirm_layout;
    }

    @Override
    protected void doSetupData() {

    }

    @Override
    protected void doInitSubView(View view) {
        TextView tv_message = ViewHelper.queryViewById(view, R.id.tv_message);
        if (!StringHelper.isEmpty(getMessage())) {
            tv_message.setText(getMessage());
        }
        Button positiveButton = ViewHelper.queryViewById(view, R.id.positiveButton);
        Button negativeButton = ViewHelper.queryViewById(view, R.id.negativeButton);
        if (!StringHelper.isEmpty(getPositiveButtonText())) {
            positiveButton.setText(positiveButtonText);
            if (positiveButtonClickListener != null) {
                positiveButton.setOnClickListener(new View.OnClickListener() {
                    public void onClick(View v) {
                        positiveButtonClickListener.onClick(getDialog(), DialogInterface.BUTTON_POSITIVE);
                    }
                });
            }
        } else {
            positiveButton.setVisibility(View.GONE);
        }

        if (!StringHelper.isEmpty(getNegativeButtonText())) {
            negativeButton.setText(negativeButtonText);
            if (negativeButtonClickListener != null) {
                negativeButton.setOnClickListener(new View.OnClickListener() {
                    public void onClick(View v) {
                        negativeButtonClickListener.onClick(getDialog(), DialogInterface.BUTTON_NEGATIVE);
                    }
                });
            }
        } else {
            negativeButton.setVisibility(View.GONE);
        }
    }


}
